using Microsoft.AspNetCore.Mvc;
using TMS.Application.Common.Interface;
using TMS.Application.Utils;
using TMS.Domain.Entity;

namespace TMS.Api.Controllers
{
    [ApiController]
    public class TeachersideController : ControllerBase
    {
        private readonly IRepository<Class> _Class;
        private readonly IRepository<Students> _Students;
        private readonly IRepository<Teachers> _Teachers;
        public TeachersideController(IRepository<Class> Class, IRepository<Students> Students, IRepository<Teachers> Teachers)
        {
            _Class = Class;
            _Students = Students;
            _Teachers = Teachers;
        }
        //获取教师列表
        [HttpGet("/StudentQuery")]
        public dynamic StudentQuery()
        {
            var Student = _Students.Table.ToList();
            var StuList = Student.Select(x => new { x.Id, x.StudentName }).ToList();
            if (StuList != null)
            {
                return new
                {
                    code = 200,
                    msg = "成功！！！",
                    data = StuList
                };
            }
            else
            {
                return new
                {
                    code = 400,
                    msg = "成功！！！",
                    data = "null"
                };
            }
        }
        //获取登录的教师信息
        [HttpGet("/TeacherInfo/{TeacherId}")]
        public async Task<object> TeacherInfo(string TeacherId)
        {
            var Teacher = _Teachers.Table.ToList();
            var Id = Teacher.Where(x => x.TeacherId == TeacherId).FirstOrDefault();
            if (Id!=null)
            {   
                var obj = new {
                    Id.Id,
                    Id.TeacherId,
                    Id.TeacherName,
                    Id.PhoneNumber,
                    Id.ChattingNumber
                };
                return new
                {
                    code = 200,
                    msg = "查找成功",
                    data = obj
                };
            }
            else
            {
                 return new
                {
                    code = 400,
                    msg = "未找到用户信息",
                    data = "null"
                };
            }

        }
        // [HttpGet("/ClassRoster/{TeacherId}")]
        // public async Task<object> ClassRoster(string TeacherId)
        // {   
            
        //     return new {

        //     };
        // }
    }
}